package com.efast.dmom.mes.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.dmom.mes.bean.QualityCheckOperation;
import com.efast.dmom.mes.bean.ResultBean;
import com.efast.dmom.mes.bean.base.IModificationFlags;
import com.efast.dmom.mes.service.QualityCheckOperationService;

@Controller
@RequestMapping("/qualityCheckOperation")
public class QualityCheckOperationController {
	@Autowired
	private QualityCheckOperationService QualityCheckOperationService;
	
	@RequestMapping(value = "/checkOperationAddOrEdit")
	public @ResponseBody ResultBean save(@RequestBody QualityCheckOperation qualityCheckOperation) {
		ResultBean resultBean = new ResultBean(true,' ');
		// Judge to add
		if (qualityCheckOperation.getModificationFlag()== IModificationFlags.NEW) {
					return QualityCheckOperationService.save(qualityCheckOperation);
				// Judge to update
		} else if (qualityCheckOperation.getModificationFlag() == IModificationFlags.MODIFIED) {
					return QualityCheckOperationService.update(qualityCheckOperation);
		}
		return resultBean;
	}
	
	@RequestMapping(value = "/batchDeleteById")
	public @ResponseBody ResultBean batchDeleteById(@RequestBody List<QualityCheckOperation> list) {
		ResultBean batchDeleteById = QualityCheckOperationService.batchDeleteById(list);
		return batchDeleteById;
	}

}
